package com.neural.parser;

import java.util.List;

import com.neural.infrastructure.Connection;
import com.neural.infrastructure.Layer;
import com.neural.infrastructure.Net;
import com.neural.infrastructure.Neuron;
import com.neural.infrastructure.ResultPojo;

public class NetPrettyPrinter {


	public static void printResults(List<ResultPojo> resultPojos) {
		StringBuilder builder = new StringBuilder("ResultPojoSets: \n");
		for (ResultPojo resultPojo : resultPojos) {
			builder.append("\tResultPojo: \n");
			builder.append("\t\tInput: " + resultPojo.getInputs()+"\n");
			builder.append("\t\tOutput: " + resultPojo.getOutputs() + "\n");
			builder.append("\t\tExpected: " + resultPojo.getExpecteds() + "\n");
			builder.append("\t\tErrors: " + resultPojo.getErrors() + "\n");
			builder.append("\n");
		}
		builder.append("\n\n");
		System.out.println(builder.toString());
	}
	
	public static void printNet(Net net) {
		StringBuilder builder = new StringBuilder();
		for(Layer layer : net.getLayers()) {
			builder.append("---------------------\n");
			builder.append(layer.getNeurons().size() + " " + layer.getActivationMethod().getName() + "\n");
		}
		builder.append("\n\n");
		System.out.println(builder.toString());
	}

	public static void printWeights(Net net) {
		StringBuilder builder = new StringBuilder("Weights: \n");
		for(Layer layer : net.getLayers()) {
			builder.append("------------------------------------------------------------------\n");
			for(Neuron neuron : layer.getNeurons()) {
				if (neuron.getPreConnections().size() == 0) {
					builder.append("none");
				} else {
					builder.append("[" + neuron.getBias() + "]\t");
					for (Connection connection : neuron.getPreConnections()) {
						builder.append(connection.getWeight() + "\t");
					}
				}
				builder.append("\n");
			}
		}
		builder.append("\n\n");
		System.out.println(builder.toString());
	}

	public static void printValues(Net net) {
		StringBuilder builder = new StringBuilder("Values: \n");
		for(Layer layer : net.getLayers()) {
			builder.append("------------------------------------------------------------------\n");
			for(Neuron neuron : layer.getNeurons()) {
				builder.append(neuron.getValue());
				builder.append("\t");
			}
			builder.append("\n");
		}
		builder.append("\n\n");
		System.out.println(builder.toString());
	}
}
